/*
 *  TCSS 343 - Winter 2012
 *  Homework 6b - Group 6
 *  
 *  Author: Daniel Anderson, Tony Butterfield, and Alan Miles   
 */
package main;

import startercode.Vertex;

/**
 * PrimVertex class.
 * wraps a vertex object for use with a PrimsGraph
 * 
 * @author Daniel Anderson
 * @author Tony Butterfield
 * @author Alan Miles
 * @version 03/08/2012
 */
public class PrimsVertex implements Comparable<PrimsVertex>
{
  // Instance Fields ************************************************
  /** vertex object being wrapped. */
  private Vertex my_vertex;
  
  /** boolean "known" status. */
  private boolean my_status;  
  
 /** pointer to closest node in known set. */
  private PrimsVertex my_pathnode;
  
  /** index of PrimVertex in the minheap. */
  private int my_heap_index;
  
  /** weight label.  */
  private Double my_weight;
  
  
  // Constructor ****************************************************  
  /**
   * constructor for PrimVertex object.
   * @param the_vertex to be wrapped 
   */
  public PrimsVertex(final Vertex the_vertex)
  {
    my_vertex = the_vertex;   // PrimsVertex.my_vertex points to Vertex
    my_vertex.setData(this);  // Vertex.data points to this PrimsVertex
    
    initialize();    
  }
  
  
  // Mutators *******************************************************
  /**
   * set PrimVertex's "known" state to true.
   */
  public void setKnown()
  {
    my_status = true;
  }
  
  /**
   * set PrimVertex's weight label
   */
  public void setWeight(final Double the_weight)
  {
    my_weight = the_weight;
  }
  
  /**
   * set PrimVertex's previous pathnode.
   * @param the_pathnode "known" PrimVertex closest to this node
   */
  public void setPathnode(final PrimsVertex the_pathnode)
  {
    my_pathnode = the_pathnode;
  }
  
  /**
   * set PrimVertex's current heap index.
   * @param the_index of the PrimVertex within the minheap
   */
  public void setHeapIndex(final int the_index)
  {
    my_heap_index = the_index;
  }
  
  
  // Accessors ******************************************************
  /**
   * test "known state.
   */
  public boolean isKnown()
  {
    return my_status;
  }
  
  /**
   * get current weight label.
   */ 
  public Double getWeight()
  {
    return my_weight;
  }
  
  /**
   * get vertex
   */
  public Vertex getVertex() 
  {
	return my_vertex;  
  }
  
  /**
   * get the known vertex currently set as closest.
   */
  public PrimsVertex getPathnode()
  {
    return my_pathnode;
  }
  
  /**
   * get current heap index.
   */
  public int getHeapIndex()
  {
    return my_heap_index;
  }
  
  
  // Methods ********************************************************
  /**  
   * initialize PrimsVertex.
   */
  private void initialize()
  {
    my_status = false;
    my_pathnode = null;//TODO This may be fine.
    my_heap_index = 0;//TODO
    
  }
  
  /**
   * compareTo method
   */
  @Override
  public int compareTo(PrimsVertex the_other)
  {
    
    int result = 0;

    if ((this == the_other)||(this.getWeight() == the_other.getWeight()))
    {
      result = 0;     // EQUAL
    }
    else if (this.getWeight() < the_other.getWeight())
    {
      result = -1;    //BEFORE
    }
    else if (this.getWeight() > the_other.getWeight())
    {
      result = 1;     // AFTER
    }
    
    return result;
  }


  

  
 
}
